<include file='Index/header'/>
<script language="javascript" type="text/javascript" src="__PUBLIC__/My97DatePicker/WdatePicker.js"></script>
<include file='Index/left'/>

<div class="content">

    <div class="header">

        <h1 class="page-title">课程安排</h1>
    </div>

    <ul class="breadcrumb">
        <li><a href="{:U('Index/Index')}">首页</a> <span class="divider">/</span></li>
        <li class="active">课程管理</li>
    </ul>

    <div class="container-fluid">
        <div class="row-fluid">

            <div class="btn-toolbar">
                <button class="btn btn-primary" onclick="showaddkc()"><i class="icon-plus"></i>添加课程</button>

                <button class="btn" onclick="window.location='__CONTROLLER__/Daochu/fs/Curr'">导出Excel</button>
                <div class="btn-group">
                </div>
            </div>
            <div class="well well-sm">
                <form id="cx" name="cx" method="get" action="__CONTROLLER__/Currinfo">
                    <lable>班次编号：</lable>
                    <input type="text" name="courseid" placeholder="" value="{$Think.session.courseid}" style="width:80px">&nbsp;&nbsp;&nbsp;&nbsp;
                    <lable>课程名称：</lable>
                    <input type="text" name="coursename" placeholder="" value="{$Think.session.coursename}"
                           style="width:80px"> &nbsp;&nbsp;&nbsp;&nbsp;
                    <lable>授课人：</lable>
                    <select name="teacher" id="teacher" style="width:100px;">
                        <option value="">授课人</option>
                        <volist name="telist" id="va">
                            <option value="{$va.tname}">{$va.tname}</option>
                        </volist>
                    </select>&nbsp;&nbsp;&nbsp;&nbsp;
                    <lable>教室：</lable>
                    <select name="class" id="class" style="width:100px;">
                        <option value="">教室</option>
                        <volist name="classs" id="vb">
                            <option value="{$vb.classname}">{$vb.classname}</option>
                        </volist>
                    </select> &nbsp;&nbsp;&nbsp;&nbsp; <br/>
                    <lable>起止时间：</lable>
                    <input type="text" name="start_time" placeholder="" value="{$Think.session.start_time}"
                           style="width:80px" onClick="WdatePicker()">
                    &nbsp;~&nbsp;
                    <input type="text" name="end_time" placeholder="" value="{$Think.session.end_time}"
                           style="width:80px" onClick="WdatePicker()">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="btn btn-primary" onclick="submit()">
                    &nbsp;&nbsp;查&nbsp;&nbsp;询&nbsp;&nbsp;
                </button>
                </form>


            </div>
            <div class="well" id='well2'>
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th nowap='nowap'>编号</th>
                        <th nowrap="">班次编号</th>
                        <th nowap='nowap'>课程名称</th>

                        <th nowap='nowap'>日期</th>

                        <th nowap='nowap'>授课人</th>
                        <th nowap='nowap'>授课内容</th>
                        <th nowap='nowap'>教室</th>
                        <th nowap='nowap'>人数</th>

                        <th style="width: 26px;"></th>
                    </tr>
                    </thead>
                    <tbody>
                    <volist name="tinfo" id="vo">
                        <tr>
                            <td nowrap="">{$vo.id}</td>
                            <td nowrap="">{$vo.courseid}</td>
                            <td nowrap="">{$vo.coursename}</td>

                            <td nowrap="">{$vo.start_time}</td>

                            <td nowrap="">{$vo.teacher}</td>
                            <td nowrap="">{$vo.lesson}</td>

                            <td nowrap="">{$vo.class}</td>
                            <td nowrap="">{$vo.number}</td>


                            <td nowrap="">
                                <a href="__CONTROLLER__/Currxg/id/{$vo.id}"><i class="icon-pencil"></i></a>
                                <a onclick="return confirm('正在删除课程：{$vo.coursename}，请确认')"
                                   href="__CONTROLLER__/del/lb/curr/id/{$vo.id}"><i class="icon-remove"></i></a>

                            </td>
                        </tr>

                    </volist>

                    </tbody>
                </table>
            </div>

            {$page}

            <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
                 aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close"
                                    data-dismiss="modal" aria-hidden="true">
                                &times;
                            </button>
                            <h4 class="modal-title" id="myModalLabel">
                                班次列表
                            </h4>
                        </div>
                        <div>
                            <div id='listsp'></div>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>
            <div class="modal fade" id="myModal2" tabindex="-1" role="dialog"
                 aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close"
                                    data-dismiss="modal" aria-hidden="true">
                                &times;
                            </button>
                            <h4 class="modal-title" id="myModalLabel">
                                选择班次
                            </h4>
                        </div>
                        <div>
                            <form id="form1" name="form1" method="post" action="__CONTROLLER__/addcurr">
                                <input type="text" value="" name="bcbh" id="bcbh" onkeyup="bccx()"
                                       placehode="请输入班次名称或班次编号"> &nbsp;&nbsp;&nbsp;&nbsp;<button type="button"
                                                                                                 class="btn btn-primary"
                                                                                                 onclick="submit()">
                                &nbsp;&nbsp;&nbsp;&nbsp;提&nbsp;&nbsp;交&nbsp;&nbsp;&nbsp;&nbsp;
                            </button>
                                <input type="hidden" value="" name="bh" id="bh">
                                <input type="hidden" value="" name="mc" id="mc">
                                <div style="border:solid 1px #ccc">
                                    <ul id="bs">

                                    </ul>
                                </div>
                            </form>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>
            <script type="text/javascript">
                function bccx() {

                    $('#bs li').remove();

                    var bcbh = $("#bcbh").val();

                    $.ajax({
                        type: "POST",
                        url: "__CONTROLLER__/showbc",

                        cache: false,
                        datatype: "json",
                        data: {
                            kcname: bcbh

                        },

                        success: function (data) {
                            //var dataObj = eval(data);


                            var datat = JSON.stringify(data);
                            for (i = 0; i < datat.length; i++) {

                                $("#bs").append("<li><a href='#' onclick=sel('" + data[i].schename + "','" + data[i].scheid + "')>" + data[i].schename + "(" + data[i].scheid + ")" + "</a></li>");
                            }
                        }

                    });


                }

                function sel(schename, scheid) {

                    $('#bcbh').val(schename + '(' + scheid + ')');
                    $('#bh').val(scheid);
                    $('#mc').val(schename);
                }

                function showaddkc() {
                    $('#bcbh').css({"margin-left": "20px"});
                    $('#myModal2').modal('show');
                    $('#myModal2').modal().css({
                        width: '500px',
                        height: '500px',
                        'margin-left': function () {
                            return -($(this).width() / 2);
                        }
                    });


                }

                function showlist() {
                    var bcbh = $("#cour").text();
                    $.ajax({
                        type: "POST",
                        url: "__CONTROLLER__/showlist",

                        cache: false,
                        data: {
                            kcname: bcbh

                        },

                        success: function (data) {

                            $('#listsp').html(data);
                            $('#myModal').modal('show');
                            $('#myModal').modal().css({
                                width: 'auto',
                                height: '500px',
                                'margin-left': function () {
                                    return -($(this).width() / 2);
                                }
                            });
                        }


                    });


                }
            </script>

            <include file='Index/footer'/>
